<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>插件临时管理</title>
    <link href="https://cdn.bootcss.com/jsoneditor/7.0.4/jsoneditor.min.css" rel="stylesheet">
    <script type="text/javascript" src="/scripts/libs/json/jsoneditor.min.js"></script>
    <#include "../plugin.ftl"/>

</head>
<body>
<div id="pluginConf" v-cloak style="width: 60%;margin: 0 auto">
<h1>插件临时管理</h1>
    <div id="app">
    <form>
        插件自增id<br/>
        <input type="text" id="id" v-model="id"/><br/>

        <input type="button" value="查询" id="select" v-on:click="getPluginInfo"/>
        <input type="button" value="更新" id="update" v-on:click="addOrUpdate"/><br/>

        模块类型<br/>
        <input type="text" id="module_type" v-model="module_type"/><br/>

        插件业务id<br/>
        <input type="text" id="plugin_id" v-model="plugin_id"/><br/>

        插件分类<br/>
        <input type="text" id="type" v-model="type"/><br/>

        插件名称<br/>
        <input type="text" id="plugin_name" v-model="plugin_name"/><br/>

        插件包名<br/>
        <input type="text" id="package_name" v-model="package_name"/><br/>

        插件业务分类<br/>
        <input type="text" id="category" v-model="category"/><br/>

        插件参数 null:<input type="checkbox" name="params_check" v-model="params_check" value="check"/><br/>
        <textarea id="params" v-model="params"></textarea><br/>

        插件数据 null:<input type="checkbox" name="data_check" v-model="data_check" value="check"><br/>
        <textarea id="data" v-model="data_"></textarea><br/>

        主页最低版本<br/>
        <input type="text" id="home_version" v-model="home_version"/><br/>

        插件最低版本<br/>
        <input type="text" id="plugin_version" v-model="plugin_version"/><br/>

    </form>
    </div>
</div>
<script>
    var app = new Vue(
        {
            el: '#app',
            data: {
                id:'',
                module_type:'',
                plugin_id:'',
                type:'',
                plugin_name:'',
                package_name:'',
                category:'',
                params:'',
                params_check:[],
                data_:'',
                data_check:[],
                home_version:'',
                plugin_version:'',
            },
            methods: {
                getPluginInfo: function() {
                    var req_data = {
                        id: this.id
                    }
                    var req = {
                        data:req_data,
                        url:"/myExtend/internalPluginConf/getDetailInfo",
                        method:"GET"
                    }
                    this.ccAjax(req).done(function(resp){
                        if (resp.code === "0"){
                            var resp_data = resp.data;
                            this.module_type=resp_data.moduleType;
                            this.plugin_id=resp_data.pluginId;
                            this.type=resp_data.type;
                            this.plugin_name=resp_data.pluginName;
                            this.package_name=resp_data.packageName;
                            this.category=resp_data.category;
                            if (resp_data.params == null) {
                                this.params_check[0]='check'
                            } else {
                                this.params=resp_data.params
                            }
                            if (resp_data.data == null) {
                                this.data_check[0]='check'
                            } else {
                                this.data=resp_data.data
                            }
                            this.home_version=resp_data.homeVersion;
                            this.plugin_version=resp_data.pluginVersion;
                        }
                    }.bind(this))
                },
                addOrUpdate: function(){
                    var plugin_info={
                        id:this.id,
                        moduleType:this.module_type,
                        pluginId:this.plugin_id,
                        type:this.type,
                        pluginName:this.plugin_name,
                        packageName:this.package_name,
                        category:this.category,
                        homeVersion:this.home_version,
                        pluginVersion:this.plugin_version
                    };
                    if (this.params_check.length === 0) {
                        plugin_info.params=this.params
                    }
                    if (this.data_check.length === 0) {
                        plugin_info.data=this.data_
                    }

                    var jsonStr=JSON.stringify(plugin_info);
                    var req={
                        data:{jsonStr:jsonStr},
                        url:"/myExtend/internalPluginConf/addOrUpdate",
                        method:"POST"
                    }
                    this.ccAjax(req).done(function(resp){
                        if (resp.code === "0"){
                            alert("更新成功")
                        }
                    }.bind(this))
                }
            }
        }
    )
</script>
</body>